package beans;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MainBean {
	protected HttpServletRequest request = null;
	protected HttpServletResponse response = null;
	protected boolean error = false;
	protected String lastErrorsMessage = "";
	public boolean isError() {
		return error;
	}
	public String getLastErrorsMessage() {
		return lastErrorsMessage;
	}
	public HttpServletRequest getRequest() {
		return request;
	}
	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}
	public HttpServletResponse getResponse() {
		return response;
	}
	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}
	public long getLongFromParam(String param) {
		String value = request.getParameter(param); 
		if(value==null) {
			return 0;
		}
		try{
			return Long.parseLong(value);
		}catch(Exception e) {
			return 0;
		}
	}
	public String getStringFromParam(String param){
		String value = request.getParameter(param);
		if(value == null || value.isEmpty()){
			return "";
		}
		return value;
	}
}
